<?php
namespace Admin\Controller;
use Think\Controller;
class LoginController extends Controller {

    public function index(){
        if(IS_POST){
            $info['username'] = I("username");
            $info['password'] = md5(I("password"));
            $user = M("admin") -> where($info) -> select();
            if(!$user){
                $this -> error("账号密码错误");
            }else{
                session('user',$info);
                $info = M("logininfo") -> select();
                $info[0]['signNum'] += $info[0]['signnum'] + 1;
                $info[0]['ip'] = $_SERVER['REMOTE_ADDR'];
                $info[0]['logintime'] = time();
                unset($info[0]['id']);
                unset($info[0]['signnum']);
                $date = M('logininfo') -> where("id = 1") -> save($info[0]);
                $this -> success("登录成功",U('Index/index'));
            }
        }
        $this->display();
    }

    public function verify(){
        $config =    array(
            'fontSize'    =>    30,    // 验证码字体大小
            'length'      =>    1,     // 验证码位数
            'useNoise'    =>    false, // 关闭验证码杂点
        );
        $Verify =     new \Think\Verify($config);
        $Verify->entry();
    }
}